package com.webSite.demo.cy.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.webSite.demo.cy.interceptor.MyInterceptor;

@Configuration
public class MyConfig implements WebMvcConfigurer{
	
	@Autowired
	private MyInterceptor interceptor;
	
	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		//配置公共访问页面(测试版)
		registry.addViewController("/fzhok.html").setViewName("/");
		registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
		WebMvcConfigurer.super.addViewControllers(registry);
	}
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//配置拦截器，取出静态页面
		registry.addInterceptor(interceptor).addPathPatterns("/fzhok.html","/").excludePathPatterns("/css/**","/js/**");
		WebMvcConfigurer.super.addInterceptors(registry);
	}
	
}
